Reduce projections during unification#20730
Reduce projections during unification#20730Tragicus wants to merge 2 commits intorocq-prover:masterfrom
Conversation
|
May I ask for a bench? |
|
@coqbot bench now |
|
🏁 Bench results: INFO: failed to install rocq-mathcomp-fingroup (dependency rocq-mathcomp-ssreflect failed) 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 0.0609 31.3 31.2867 51367.11% 369 coq-bedrock2/bedrock2/src/bedrock2Examples/LAN9250.v.html │ │ 0.0246 7.15 7.1227 28991.81% 368 coq-bedrock2/bedrock2/src/bedrock2Examples/LAN9250.v.html │ │ 0.00502 0.797 0.7918 15761.05% 369 coq-bedrock2/bedrock2/src/bedrock2Examples/LAN9250.v.html │ │ 17.4 18.1 0.7081 4.07% 31 coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html │ │ 5.78 6.47 0.6814 11.78% 628 coq-bedrock2/bedrock2/src/bedrock2Examples/LAN9250.v.html │ │ 2.33 2.90 0.5732 24.65% 607 rocq-stdlib/theories/Zmod/ZmodBase.v.html │ │ 45.3 45.9 0.5057 1.12% 118 coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 3.09 3.55 0.4580 14.83% 196 rocq-stdlib/theories/ZArith/ZModOffset.v.html │ │ 1.22 1.58 0.3592 29.43% 1142 rocq-stdlib/theories/FSets/FMapAVL.v.html │ │ 1.44 1.77 0.3323 23.05% 313 rocq-stdlib/theories/Strings/Byte.v.html │ │ 0.266 0.589 0.3239 121.97% 12 rocq-stdlib/theories/MSets/MSets.v.html │ │ 23.7 24.1 0.3163 1.33% 558 coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html │ │ 1.14 1.42 0.2795 24.61% 207 rocq-stdlib/theories/setoid_ring/Ncring_tac.v.html │ │ 9.95 10.2 0.2765 2.78% 214 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 9.83 10.1 0.2718 2.77% 325 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 0.118 0.351 0.2338 198.85% 12 rocq-stdlib/theories/Reals/Abstract/ConstructiveAbs.v.html │ │ 1.02 1.25 0.2258 22.15% 572 rocq-stdlib/theories/MSets/MSetAVL.v.html │ │ 0.357 0.583 0.2257 63.22% 13 rocq-stdlib/theories/Numbers/DecimalFacts.v.html │ │ 0.200 0.423 0.2235 111.98% 14 rocq-stdlib/theories/Numbers/Cyclic/Int63/Uint63.v.html │ │ 0.000564 0.207 0.2062 36553.37% 16790 coq-coqprime/src/Coqprime/examples/BasePrimes.v.html │ │ 0.245 0.450 0.2051 83.61% 34 rocq-stdlib/theories/Logic/SetoidChoice.v.html │ │ 17.7 17.9 0.2012 1.14% 670 coq-performance-tests-lite/src/Nia.v.html │ │ 0.231 0.412 0.1813 78.64% 131 rocq-stdlib/theories/MSets/MSetProperties.v.html │ │ 0.359 0.528 0.1693 47.18% 443 rocq-stdlib/theories/Reals/Abstract/ConstructiveLimits.v.html │ │ 1.09 1.25 0.1623 14.92% 408 rocq-stdlib/theories/MSets/MSetAVL.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 200 199 -0.8396 -0.42% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 1.46 0.779 -0.6822 -46.68% 559 coq-bedrock2/bedrock2/src/bedrock2Examples/LAN9250.v.html │ │ 65.9 65.4 -0.5738 -0.87% 609 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 100 99.7 -0.4369 -0.44% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 99.9 99.6 -0.3630 -0.36% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 1.50 1.22 -0.2720 -18.17% 75 rocq-stdlib/theories/Numbers/HexadecimalString.v.html │ │ 0.468 0.210 -0.2577 -55.07% 1982 rocq-stdlib/theories/FSets/FMapFacts.v.html │ │ 0.619 0.366 -0.2536 -40.94% 208 rocq-stdlib/theories/setoid_ring/Ncring_tac.v.html │ │ 0.950 0.698 -0.2525 -26.57% 41 rocq-stdlib/theories/ZArith/Zdiv_facts.v.html │ │ 0.461 0.213 -0.2481 -53.82% 17 rocq-stdlib/theories/micromega/Env.v.html │ │ 0.466 0.218 -0.2480 -53.24% 11 rocq-stdlib/theories/micromega/ZifyComparison.v.html │ │ 1.16 0.925 -0.2390 -20.54% 2109 rocq-stdlib/theories/FSets/FMapFacts.v.html │ │ 0.616 0.379 -0.2375 -38.53% 10 rocq-stdlib/theories/extraction/ExtrHaskellZNum.v.html │ │ 0.201 0.000527 -0.2002 -99.74% 16783 coq-coqprime/src/Coqprime/examples/BasePrimes.v.html │ │ 22.1 21.9 -0.1990 -0.90% 651 rocq-stdlib/theories/Zmod/ZmodBase.v.html │ │ 39.0 38.8 -0.1968 -0.50% 236 coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 0.516 0.330 -0.1862 -36.10% 11 rocq-stdlib/theories/setoid_ring/Rings_Z.v.html │ │ 0.958 0.774 -0.1836 -19.16% 813 rocq-stdlib/theories/MSets/MSetRBT.v.html │ │ 0.402 0.225 -0.1775 -44.15% 759 rocq-stdlib/theories/MSets/MSetRBT.v.html │ │ 0.371 0.200 -0.1714 -46.17% 172 rocq-stdlib/theories/FSets/FSetFacts.v.html │ │ 0.788 0.618 -0.1693 -21.49% 816 rocq-stdlib/theories/MSets/MSetRBT.v.html │ │ 38.2 38.0 -0.1664 -0.44% 224 coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html │ │ 0.714 0.555 -0.1588 -22.23% 160 rocq-stdlib/theories/Numbers/HexadecimalNat.v.html │ │ 0.576 0.418 -0.1585 -27.50% 705 rocq-stdlib/theories/Numbers/HexadecimalFacts.v.html │ │ 0.260 0.109 -0.1511 -58.00% 25 rocq-stdlib/theories/Logic/ClassicalChoice.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
When encountering a projection, we weak-head reduce its subject. If we obtain a constructor, we reduce the projection immediately (without backtracking). Otherwise and if the reduced subject is not ground, we try solving the canonical structure problem after refolding the other term to its state at the start of the unification.
|
The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed. |
|
This PR was not rebased after 30 days despite the warning, it is now closed. |
Unifying structures is very slow (see e.g. math-comp/math-comp#1365). So whenever we see a projection, we can try to reduce it. This also simplifies the Canonical Structures procedure (e.g. gets rid of the "keys" and
restores the previous reduction strategyavoids backtracking in the reduction strategy).Fixes / closes #????
make doc_gram_rsts.Overlays: